package exam.test3;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2020-07-27
 * Time: 21:42
 */
public class SuperHeroes {
    public static void main(String[] args) {
//        SheRa[] superHeroess = {new Skeletor(), new HeMan(), new SheRa(), new BattleCat()};
//
//        for (int i = 0; i < superHeroess.length; i++) {
//            superHeroess[i].train();
//            System.out.println();
//            superHeroess[i].attack();
//            System.out.println();
//            System.out.println(superHeroess[i]);
//            System.out.println();
//        }

        ArrayList<String> ont = new ArrayList<>(Arrays.asList("score", "four", "seven", "and", "age", "year","1","2"));
        switchPairs(ont);
        System.out.println(ont);
    }

    public static void switchPairs(ArrayList<String> list) {
        if (list == null || list.size() <= 1) {
            return;
        }
        for (int i = 0; i + 1 < list.size(); i += 2) {
            String tmp = list.get(i);
            list.set(i, list.get(i + 1));
            list.set(i + 1, tmp);
        }

    }
}
